package com.lagou.edu.controller;

import com.lagou.edu.pojo.AuthCode;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/email")
public class EmailController {

//    @Autowired
//    private EmailConfig emailConfig;

    @RequestMapping("/send/code")
    public ModelMap sendCode(@RequestBody AuthCode authCode) {
        ModelMap modelMap = new ModelMap();
        try {
//            emailConfig.sendMail(authCode.getEmail(), authCode.getCode());
            System.out.println("发送的邮箱：" + authCode.getEmail() + "，验证码为：" + authCode.getCode());
            modelMap.addAttribute("code", 200);
            modelMap.addAttribute("message", "已发送");
        } catch (Exception e) {
            modelMap.addAttribute("code", 500);
            modelMap.addAttribute("message", e.getMessage());
        }
        return modelMap;
    }

}
